home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
425_01
/
tar
/
tar.c
< prev
next >
Wrap
Text File
|
1994-04-02
|
35KB
|
1,054 lines
/* tar.c - Tape ARchive utility program (main function)
* Author: T.V.Shaporev
* Creation date: 14 Dec 1990
*
* The program works in a same fashion under UNIX (most clones) and MS-DOS.
* The main idear was to develop a tool for file transferring via diskette
* between different operating systems - such as all UNIX clones, MS-DOS,
* RSX, VAX/VMS - and all others which support tar format on a diskette.
*
* First step on this way (made in 1989) lies in adapting common UNIX tar
* program to MS-DOS.
*
* On the second step
* - some bugs were fixed (especially in DOS-applied codes) and some
* optimization were done;
* - nonstandard (under DOS) diskette formats were added (i.e.
* DEC Rainbow and 80 tracks & 9 sectors format)
* - the possibility for compress encoding were included
* (this compressor has the best ratio among all others which
* I know, but don't ask me about its speed). Compressed-file
* format is compatible with the common versions of tar, so You
* can extract the compressed image from the archive by the
* common program, but I doubt You could uncompress them at last.
*
* On the fird step the program was totally (newly) overwritten to bypass
* any copyright exclamations. In fact, it must be considered new program
* but I prefer to continue version enumeration (I hope, nobody cares).
*
* I think, this program must be called Tar (with capital first letter)
* to distinguish it from regular UNIX tar.
*
* The program's behaviour is analogous to usual tar, and I hope, its
* internal help will be enough to understand the differences.
*
* The program doesn't perform any text file conversion - it passes
* strict binary image of each file. If You has a problems with reading
* DOS text files under UNIX (or UNIX files under DOS) please use my
* dostext program.
*
* The program must be compiled by Turbo C 2.0 compiler (in a compact
* model) under MS-DOS. Please don't replace dynamic arrays back to
* static and automatic - MS-DOS compilers dislike them.
*
* tim tim@ecsc.mipt.su 14 Dec 1990
*/
/* Version 3.01
* Handling of the 'l' option corrected
*/
/* Version 3.02 31 Dec 1990
* - great deal of minor corrections
* - u<pdate> option expanded to extracting
* - j<ournal> option added (comment storying files)
* - wildcards * and ? are now processed in archive; this may be
* suppressed by s<trict> option
* - d<elete> option added to replace previous occurencies of files
* in archive on storying, or deleting files from archive when
* whithout a<dd> parameter - this is for file archives only!
*/
/* Version 3.03 22 Feb 1991
* - an error corrected in mismatch() (file extract.c)
* - decreased stack requirements for tree processing
* (see store() in store.c and putfiles() in tar.c)
* - added codes to prevent archive file self-storying
* (not quite reliable for MS-DOS)
* - bincall() invocations changed by calls to rmdir() and mkdir()
* this is done automatically for 386/ix and may be switched by
* RMKDIR macro
*/
/* Version 3.04 29 Jul 1991
* - a direct intialization of static global variables inserted into
* lzencode() and lzdecode() - see file lzpack.c
*/
/* Version 3.04b 03 Oct 1991
* - a minor correction of bincall()
* - added default block number = sectors on track (MS-DOS)
*/
/* Version 3.05 11 Nov 1991
* - block factor for diskette writing is set to 1 for most BIOS
* compatibility
* - scantape() is slightly optimized
*/
/* Version 3.06 17 Dec 1991
* - n<onest> option applied to all actions (see inarg() in extract.c)
* - command-line-extension-file option (responce file) added
* for vak (vak@kiae.su) request (see append() in tar.c)
* - p<ermission> option added to save directories permissions (UNIX)
*/
/* Version 3.06b 22 Dec 1991
* - UNIX to DOS renaming algorithm (dot elimination) slightly
* changed (see extract.c)
* - most of output redirected to stdout (vs stderr)
*/
/* Version 3.07 28 Dec 1992
* - all unary apostrofs in string constants preserved by backslashes
* - reading file list from stdin allowed (see append() in tar.c)
* - input redirected to /dev/tty under UNIX
* - support for traditional UNIX compression algorithm
* - few changes in converting UNIX names for DOS
*/
/* Version 3.07b 20 Jan 1993
* - gethead() does not return FALSE while errors,
* scantape() looks for tape reading errors
*/
/* Version 3.08 22 Feb 1993
* - method-dependent comression indicator masks (see percent.c)
* - 'z' option applied to catalog printing (see catalog())
* - compatibility corrections in directory structure checking
* - st.st_size == codesize - means file unpacked! (see extract.c)
*/
/* Version 3.09 14 Mar 1993
* - a bug fixed wich prevents archiving unpacked files at all
* (ha-ha!) - see store.c
* - changed header description to support new features
* see define.h
* - support for P1003 and GNU file types - 't' option only! -
* see extract.c
* - small changes in #ifdef-s to distinguish SCO UNIXes from
* XENIXes - see store.c
* - regular file processing extracted into separate source
* files (see savefile.c & restore.c)
* - support for devices and FIFOs added
* - 'l' option added for DOS (copy linked files)
* - support for System V extents - see extract.c and restore.c
* to read archives only, extents may not be unpacked on the
* fly - alas, that's all for now
* - an error corrected in roll.c
*/
/* Version 3.10 28 Jun 1993
* - a bug fixed in old compression code (see lzpack.c)
* - added possibility to run through compress (',' comma option)
* see tar.c, tape.c and compress.c
* - comments will not be printed unless 'j' is given (extract.c)
* - separated compress-related codes
*/
/* Version 3.11 14 Jul 1993
* - support for QIC-02 streamers (first version!)
* devices supported: fastape, everex
*/
/* Version 3.12 29 Sen 1993
* - slack area in archive is filled by nulls to improve compression
* - added support for Wangtek (QIC-02) device
* - a bug fixed in memory release ('pk_out' variable - see _done())
* - program support for QIC-02 drive number and tape format
* selection
* - experimental (!) support for appending QIC-02 tapes
* (see qback() in qicface.c)
* - LZW support splitted into compressor and extractor and
* the letter included in official release (see unlzw.c etc.)
* - get default file name from TAPE environment variable
* - 'o' flag for DOS means prevent file overwriting
*/
/* Version 3.12b 10 Nov 1993
* - an error corrected in QIC device selection (see qicface.c)
* - eliminated idle rewindings around QIC tape initialisation
*/
/* Version 3.13 26 Dec 1993
* - online inflatter (unzip) and corresponding '.' (point) option
*/
/* Version 3.14 19 Feb 1994
* - online deflatter (zip); compilation model changed to large
*/
/* Version 3.15 - general bugfix 03 Apr 1994
* - strerror() missed in some UNIXes, so psyserr() function added
* into tape.c
* - extended local header signature inserted in deflated output and
* unzclose() changed to uderstand both formats
* (see zipdefs.h, zippipe.c and diszip.c)
* - pkflush() output is aligned to pksize boundary if output is not
* regula